package com.eclipse.organigram.model.entities;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

public class TreeElement {
	
	@JsonIgnore
	private Object parent;
	
	@JsonInclude(value=Include.NON_EMPTY)
	private List<Person> team = new ArrayList<Person>();
	
	public Object getParent() {
		return parent;
	}
	
	public void setParent(Object parent) {
		this.parent = parent;
	}
	
	public void add(Person person) {
		person.setParent(this);
		team.add(person);
	}
	
	public List<Person> getTeam() {
		return team;
	}
	
	@JsonIgnore
	public Object[] getChildren() {
		return team.toArray();
	}
	
	public boolean hasChildren() {
		return !team.isEmpty();
	}

}